<?php
/**
 * Guestbook
 */
include LIB_PATH . '/YAction.class.php';
class GuestbookAction extends YAction {
	public function __construct() {
		parent::__construct();
		
		// 登录检测
		if(!$this->isLogin()) {
			echo '_error Access Timeout'; exit;
		}
	}
	
	public function index() {
		$data = D('Guestbook')->getListByPage();
		$pageString = $data['pageString'];
		unset($data['pageString']);
		$this->assign('data', $data);
		$this->assign('pageString', $pageString);
		
		$this->display();
	}
	
	public function delGuestbook() {
		$id = y_getParam('id', 'get');
		
		D('Guestbook')->deleteByCondition('id='.$id.' or pid='.$id);
		
		$this->success('删除成功');
	}
	
	public function ajax_getReply() {
		$id = y_getParam('pkid', 'get');
		if(!is_numeric($id)) {echo '2'; exit;}
		
		$data = D('Guestbook')->getByCondition('pid='.$id);
		
		echo json_encode($data);
	}
}